<%@include file="header.jsp"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<form:form id="register_form" action="registeruser.html"
	commandName="user" class="form-horizontal">
	<h2 class="form-signin-heading">Register</h2>
	<hr><div class="alert alert-error"
		<%String errorStyle = "";
				if (request.getAttribute("errors") == null)
					errorStyle = "style='display: none;'";
				else
					errorStyle = "style='display: block;'";%>
		<%=errorStyle%>>${errors}</div>
	<div class="control-group">
		<label class="control-label" for="username">Username</label>
		<div class="controls">
			<form:input id="username" name="username" path="username" type="text"
				placeholder="Username" />
			<form:errors path="username" cssClass="error" />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label" for="email">Email</label>
		<div class="controls">
			<form:input id="email" name="email" path="email" type="text"
				placeholder="Email address" />
			<form:errors path="email" cssClass="error" />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label" for="firstName">First Name</label>
		<div class="controls">
			<form:input id="firstName" name="firstName" path="firstName"
				type="text" placeholder="First Name" />
			<form:errors path="firstName" cssClass="error" />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label" for="lastName">Last Name</label>
		<div class="controls">
			<form:input id="lastName" name="lastName" path="lastName" type="text"
				placeholder="Last Name" />
			<form:errors path="lastName" cssClass="error" />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label" for="password">Password</label>
		<div class="controls">
			<form:input id="password" name="password" path="password"
				type="password" placeholder="Password" />
			<form:errors path="password" cssClass="error" />
		</div>
	</div>
	<div class="control-group">
		<label class="control-label" for="repeat_password">Confirm
			Password</label>
		<div class="controls">
			<input id="repeat_password" name="repeat_password" type="password"
				placeholder="Repeat Password" />
		</div>
	</div>
	
	<div class="control-group">
		<div class="controls">
			<button id="registerButton" class="btn btn-large btn-primary" type="submit">
				Register
			</button>
		</div>
	</div>

	
</form:form>
<script src="<spring:url value="web/js/jquery-2.0.0.js" />"></script>
<script src="<spring:url value="web/js/jquery.validate.js" />"></script>
<script src="<spring:url value="web/js/bootstrap.js" />"></script>
<script type="text/javascript">
	$('document')
			.ready(
					function() {
						$('#register_form')
								.validate(
										{
											rules : {
												username : {
													required : true,
													minlength : 4,
													maxlength : 50
												},
												email : {
													required : true,
													email : true
												},
												firstName : {
													required : true,
													maxlength : 50
												},
												lastName : {
													required : true,
													maxlength : 50
												},
												password : {
													required : true,
													minlength : 6
												},
												repeat_password : {
													required : true,
													equalTo : "#password"
												}
											},
											messages : {
												username : {
													required : "Please enter your login",
													minlength : "Login must have at least 4 sybmols"
												},
												email : {
													required : "Please enter your email",
													email : "Your email address must be in the format of name@domain.com"
												},
												firstName : "Please specify your first name",
												lastName : "Please specify your last name",
												password : {
													required : "Please enter your password",
													minlength : "Password must be at least 6 symbols"
												},
												repeat_password : {
													required : "Please repeat your password",
													equalTo : "Please enter password you entered in \"Password\" field"
												}
											}
										});
					});
</script>


<%@include file="footer.jsp"%>